package cn.com.surker.pages.console;

import cn.com.surker.base.system.entity.SysLine;
import cn.com.surker.base.system.entity.SysStorage;
import cn.com.surker.base.system.service.SysStorageService;
import cn.com.surker.common.AbstractController;
import cn.com.surker.material.service.impl.MainMaterialServiceImpl;
import cn.com.surker.oa.entity.OaMaterial;
import cn.com.surker.system.entity.SysOrigin;
import cn.com.surker.system.service.impl.SysLineServiceImpl;
import cn.com.surker.util.ReportDateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author lucky
 * @create 2024年12月30 15:14
 * @desc 技术消耗查询
 */
@Slf4j
@Controller
@RequestMapping("/console/lal-level")
public class LabExpendIndexController extends AbstractController {

    @Resource
    private SysLineServiceImpl lineService;
    @Resource
    private SysStorageService storageService;
    @Resource
    private MainMaterialServiceImpl materialService;

    /**
     * 料仓消耗查询
     * @return
     */
    @RequestMapping("/storage-expend")
    public ModelAndView storageExpend() {
        ModelAndView modelAndView = new ModelAndView();

        List<SysOrigin> orgList = getUserOrgList();
//        CacheUser user = getUser();

        Date nowDate = new Date();
        String startTime = ReportDateUtils.getMonthReportStartTime(nowDate);
        String endTime = ReportDateUtils.getMonthReportEndTime(nowDate);
        List<SysLine> lineList = lineService.findAll();
        List<SysStorage> storageList = storageService.findByOrg(orgList.get(0).getId(), null, null);
        List<OaMaterial> materialList = materialService.findByOrg(orgList.get(0).getId());
        modelAndView.addObject("startTime", startTime);
        modelAndView.addObject("endTime", endTime);
        modelAndView.addObject("lineList", lineList);
        modelAndView.addObject("storageList", storageList);
        modelAndView.addObject("materialList", materialList);
        modelAndView.addObject("orgList", orgList);
        modelAndView.setViewName("console/lab/storage-expend");
        return modelAndView;
    }

}
